/**
 * Project Name:fire-industry-DM-center
 * File Name:HttpResponseUtil.java
 * Package Name:com.firestone.core.utils
 * Date:2018年3月28日下午4:17:19
 *
*/

package com.firestone.core.utils;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.firestone.bean.dto.ReturnDTO;
import com.firestone.core.enums.SystemCodeEnum;

/**
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author CAIYJ
 * @date 2018年3月28日 下午4:17:19
 */
public class HttpResponseUtil {

    public static void noUser(HttpServletResponse response) throws IOException {
        response.setContentType("application/json");
        response.setCharacterEncoding("utf-8");
        response.getWriter().write(JSON.toJSONString(
                ReturnDTO.fail(SystemCodeEnum.userpwd_not_exist)));
        response.getWriter().flush();
        response.getWriter().close();
    }

    public static void noAuth(HttpServletResponse response) throws IOException {
        response.setContentType("application/json");
        response.setCharacterEncoding("utf-8");
        response.getWriter().write(JSON.toJSONString(
                ReturnDTO.fail(SystemCodeEnum.http_status_forbidden)));
        response.getWriter().flush();
        response.getWriter().close();
    }

    public static void noLogin(HttpServletResponse response)
            throws IOException {
        response.setContentType("application/json");
        response.setCharacterEncoding("utf-8");
        response.getWriter().write(
                JSON.toJSONString(ReturnDTO.fail(SystemCodeEnum.no_login)));
        response.getWriter().flush();
        response.getWriter().close();
    }
}
